/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmDetailNanny1.java
 *
 * Created on Nov 27, 2011, 10:45:44 PM
 */
package GUI;
import DAO.Connect;
import DatabaseAccess.quanLyBaoMau;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
 *
 * @author Dell
 */
public class FrmDetailNanny1 extends javax.swing.JFrame {
    DefaultTableModel model;
    Connection conn;
    Statement st;
    PreparedStatement pstmt;
    ResultSet rs;
    quanLyBaoMau nhap = new quanLyBaoMau();
    Connect connect = new Connect();
    /** Creates new form FrmDetailNanny1 */
    public FrmDetailNanny1() {
        initComponents();
           conn = connect.getConnection();
        try {
          String strSql = "select NannyID,Name,DateOfBirth,Address,ContactNumber,ChargePaidToHer,WorkingHours from tblNanny where NannyID=?";
        pstmt = conn.prepareStatement(strSql);
        pstmt.setString(1, FrmQuanLyBaoMau1.NannyIDD);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            lbID.setText(rs.getString(1));
            lbName.setText(rs.getString(2));
             lbBirthday.setDate(rs.getDate(3));
            lbAddress.setText(rs.getString(4));
            lbPhone.setText(rs.getString(5));
            lbCharge.setText(rs.getString(6));
            lbworkinghours.setText(rs.getString(7));

        }
        conn.close();
    } catch (SQLException ex) {
                ex.printStackTrace();
                JOptionPane.showMessageDialog(this,"Error:"+ex.getMessage());
              return;
    }
             Listclass.setModel(new DefaultListModel());
            InitListClassOfNanny(Listclass);
    }
        public void InitListClassOfNanny(JList jlist){
        try {
            conn=connect.getConnection();
            String MySql = "SELECT c.ClassName,c.AgeGroupID FROM tblDetailsClassNanny d join tblClass c on d.ClassID=c.ClassID where NannyID=?";           
            pstmt = conn.prepareStatement(MySql);
            pstmt.setString(1,FrmQuanLyBaoMau1.NannyIDD);
            ResultSet rs = pstmt.executeQuery();
            while(rs.next()){
                String name=rs.getString(1);
                String age=rs.getString(2);
                ((DefaultListModel) Listclass.getModel()).addElement(name +"  :"+age);
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        lblNannyID = new javax.swing.JLabel();
        lblName = new javax.swing.JLabel();
        lblBirthday = new javax.swing.JLabel();
        lblAddress = new javax.swing.JLabel();
        lblContactNumber = new javax.swing.JLabel();
        lblCharge = new javax.swing.JLabel();
        lblWorkingHours = new javax.swing.JLabel();
        lblClassofNanny = new javax.swing.JLabel();
        lbID = new javax.swing.JLabel();
        lbName = new javax.swing.JLabel();
        lbAddress = new javax.swing.JLabel();
        lbPhone = new javax.swing.JLabel();
        lbCharge = new javax.swing.JLabel();
        lbworkinghours = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        Listclass = new javax.swing.JList();
        lbBirthday = new com.toedter.calendar.JDateChooser();
        jLabel1 = new javax.swing.JLabel();
        btnClose = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Detail Nanny");

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(255, 255, 51)));
        jPanel1.setForeground(new java.awt.Color(255, 255, 51));

        lblNannyID.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblNannyID.setForeground(new java.awt.Color(0, 0, 204));
        lblNannyID.setText("Nanny ID :");

        lblName.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblName.setForeground(new java.awt.Color(0, 0, 204));
        lblName.setText("Name :");

        lblBirthday.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblBirthday.setForeground(new java.awt.Color(0, 0, 204));
        lblBirthday.setText("Birthday :");

        lblAddress.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblAddress.setForeground(new java.awt.Color(0, 0, 204));
        lblAddress.setText("Address:");

        lblContactNumber.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblContactNumber.setForeground(new java.awt.Color(0, 0, 204));
        lblContactNumber.setText("Contact Number:");

        lblCharge.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblCharge.setForeground(new java.awt.Color(0, 0, 204));
        lblCharge.setText("Charge :");

        lblWorkingHours.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblWorkingHours.setForeground(new java.awt.Color(0, 0, 204));
        lblWorkingHours.setText("Workinghours :");

        lblClassofNanny.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblClassofNanny.setForeground(new java.awt.Color(0, 0, 204));
        lblClassofNanny.setText("Class of Nanny");

        lbID.setFont(new java.awt.Font("Tahoma", 0, 14));
        lbID.setForeground(new java.awt.Color(0, 0, 204));
        lbID.setText("a");

        lbName.setFont(new java.awt.Font("Tahoma", 0, 14));
        lbName.setForeground(new java.awt.Color(0, 0, 204));
        lbName.setText("b");

        lbAddress.setFont(new java.awt.Font("Tahoma", 0, 14));
        lbAddress.setForeground(new java.awt.Color(0, 0, 204));
        lbAddress.setText("c");

        lbPhone.setFont(new java.awt.Font("Tahoma", 0, 14));
        lbPhone.setForeground(new java.awt.Color(0, 0, 204));
        lbPhone.setText("d");

        lbCharge.setFont(new java.awt.Font("Tahoma", 0, 14));
        lbCharge.setForeground(new java.awt.Color(0, 0, 204));
        lbCharge.setText("e");

        lbworkinghours.setFont(new java.awt.Font("Tahoma", 0, 14));
        lbworkinghours.setForeground(new java.awt.Color(0, 0, 204));
        lbworkinghours.setText("f");

        Listclass.setForeground(new java.awt.Color(0, 0, 204));
        Listclass.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(Listclass);

        lbBirthday.setDateFormatString("MMMM/dd/yyyy");
        lbBirthday.setEnabled(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(61, 61, 61)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblClassofNanny)
                        .addGap(69, 69, 69)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblWorkingHours)
                        .addGap(63, 63, 63)
                        .addComponent(lbworkinghours, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblCharge)
                        .addGap(106, 106, 106)
                        .addComponent(lbCharge, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNannyID)
                            .addComponent(lblName)
                            .addComponent(lblBirthday)
                            .addComponent(lblAddress)
                            .addComponent(lblContactNumber))
                        .addGap(52, 52, 52)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbPhone, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
                            .addComponent(lbAddress, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
                            .addComponent(lbBirthday, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbID, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(lbName, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                .addGap(96, 96, 96)))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNannyID)
                    .addComponent(lbID))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblName)
                    .addComponent(lbName))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblBirthday)
                    .addComponent(lbBirthday, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblAddress)
                    .addComponent(lbAddress))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblContactNumber)
                    .addComponent(lbPhone))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbCharge)
                    .addComponent(lblCharge))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblWorkingHours, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbworkinghours))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(lblClassofNanny))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(21, 21, 21))
        );

        jLabel1.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24));
        jLabel1.setForeground(new java.awt.Color(204, 0, 0));
        jLabel1.setText("Detail Nanny");

        btnClose.setFont(new java.awt.Font("Tahoma", 0, 12));
        btnClose.setForeground(new java.awt.Color(0, 0, 204));
        btnClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/close2.png"))); // NOI18N
        btnClose.setText("Close");
        btnClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCloseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(144, 144, 144)
                .addComponent(btnClose)
                .addContainerGap(180, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(114, 114, 114)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(125, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(7, 7, 7)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 357, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnClose)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-425)/2, (screenSize.height-518)/2, 425, 518);
    }// </editor-fold>//GEN-END:initComponents

private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
        this.dispose();
}//GEN-LAST:event_btnCloseActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmDetailNanny1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmDetailNanny1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmDetailNanny1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmDetailNanny1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrmDetailNanny1().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList Listclass;
    private javax.swing.JButton btnClose;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lbAddress;
    private com.toedter.calendar.JDateChooser lbBirthday;
    private javax.swing.JLabel lbCharge;
    private javax.swing.JLabel lbID;
    private javax.swing.JLabel lbName;
    private javax.swing.JLabel lbPhone;
    private javax.swing.JLabel lblAddress;
    private javax.swing.JLabel lblBirthday;
    private javax.swing.JLabel lblCharge;
    private javax.swing.JLabel lblClassofNanny;
    private javax.swing.JLabel lblContactNumber;
    private javax.swing.JLabel lblName;
    private javax.swing.JLabel lblNannyID;
    private javax.swing.JLabel lblWorkingHours;
    private javax.swing.JLabel lbworkinghours;
    // End of variables declaration//GEN-END:variables
}
